<template>
	<view class="pages">
		<div class="title">{{info.name}}</div>
		<div class="margin-top20 flex  justify-content-between align-items">
			<div class="category">{{Txt.get(info.category - 0)  }}</div>
			<div class="date">{{info.createDate}}</div>
		</div>
		<block v-for="(item,index) in fileList" :key="index">
			 <div class="flex align-items  margin-top20" style="justify-content: flex-end;" @click="nearby(item.fileUrlShow)"> 
			   <u-icon  name="file-text-fill" size="20" style="margin-top: 5rpx;"></u-icon>
			 <span style="color: #3c9cff;">{{item.fileName}}</span>
			 </div>
		</block>
		
	</view>
</template>

<script>
	import {
		systemDetails,
	} from '@/api/rulesAndRegulations.js'
	const Txt  = new Map([
		[1,"法律法规"],
		[2,"规章制度"],
		[3,"操作规程"]
	])
	import urlConfig from "@/request/urlConfig.js";
	export default {
		data() {
			return {
				Txt,
				info: {},
				fileList: []
			};
		},
		onLoad(option) {
			uni.setNavigationBarTitle({
				title: option.name
			})
			this.getInfo(option.id, option.category)
		},
		methods: {
			getInfo(id, category) {
				systemDetails({
					id,
					category,
				}).then(res => {
					console.log(res, "res");
					this.info = res.datas.systemVo
					this.fileList = res.datas.fileList
				})
			},
			nearby(url) {
				const extensionUrl = urlConfig.nearbyUrl + url
				const extension = extensionUrl.split('.').pop().toLowerCase();
				console.log(extensionUrl, "extensionUrl");
				if (extension == 'pdf') {
					window.android.startDoc(extensionUrl);
				} else {
					window.open(extensionUrl)
				}
			},
		}
	}
</script>

<style lang="scss" scoped>
.pages{
	padding: 30rpx;
}
 .title{
	 font-size: 36rpx;
	 font-weight: 600;
 }
 .category{
	 padding: 10rpx 20rpx;
	 color: #3c9cff;
	 background-color: #ecefff;
	 border-radius: 5rpx;
 }
</style>